package com.exampler.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.TimeUnit;

@RestController
public class ProviderController {
    @Value("${server.port}")
    private String port;

    @GetMapping("/hi")
    //@SentinelResource("hi")
    public String hi(@RequestParam(value = "name",defaultValue = "forezp",required = false)String name, HttpServletRequest request){
        System.out.println(request.getHeader("token"));
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "hi "+name+"port："+port;
    }
}
